<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<AvansRS.Domain.EventDate>" %>
<%@ Import Namespace="AvansRS.Domain" %>
<%@ Import Namespace="AvansRS.Web.Util" %>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Inschrijvingen</h2>    
<%
    Entity entity = AvansRS.Web.Util.SessionHelper.GetLoggedIn(this.User)
        .Entity;
    IList<AvansRS.Domain.TimeBlock> timeBlocks = Model.Rooster.TimeBlock;%>    
        
    <br />
    <br />
    
    <table class="schedule">
        <thead>
            <tr>
                <th class="header">Uur</th><th class="header">Inschrijving</th>
            </tr>
        </thead>  
        <tbody>
            <%
               int i = 0;
               foreach (AvansRS.Domain.TimeBlock hour in timeBlocks)
               {
                   Registration registration = Model.GetRegistrationOnHour(hour);
                   string div = "";
                   string occupantName = "";
                   if(registration != null)
                   {
                       object occupant = DomainHelper.GetOccupant(registration);
                       if(occupant is Person)
                       {
                           Person person = (Person) occupant;
                           div = "<img src=\"/Content/images/User-icon.png\" />";
                           occupantName = person.FirstName + " " + person.SurName;
                       }
                       if (occupant is AvansRS.Domain.Group)
                       {
                           AvansRS.Domain.Group group = (AvansRS.Domain.Group)occupant;
                           div = "<img src=\"/Content/images/user-group-icon.png\" />";
                           occupantName = group.Name;
                       }
                   }
                   string hourStr = "";
                   if (i.ToString().Length == 2)
                       hourStr = i.ToString();
                   else
                       hourStr = "&nbsp; " + i.ToString();

                   string fullHourString = hourStr + ". " + hour.StartTime.ToShortTimeString() + " - " +
                                           hour.EndTime.ToShortTimeString();
                   %>
                        <tr id="<%=hour.ID.ToString() %>">
                        <td><%=fullHourString %></td>
                        <td>                                                                    
                            <%=div + " " + occupantName %>
                       </td>
                        </tr>
                   <%
                   i++;
               }
            %>        
        </tbody>          
    </table>

</asp:Content>